const path = require('path'); // 引入path模块
function resolve(dir) {
    return path.join(__dirname, dir) //path.join(_dirname)设置绝对路径
}

module.exports = {
    //1.起别名
    chainWebpack: (config) => {
        config.resolve.alias
        //第一个参数：别名 第二个参数：路径
            .set('components', resolve('src/components'))
            .set('assets', resolve('src/assets'))
            .set('common', resolve('src/common'))
            .set('views', resolve('src/views'))
            .set('network', resolve('src/network'))
    },
    //2.接口代理
    devServer: {
        host: 'localhost',
        port: 8080,
        proxy: {
            '/api': {
                target: "http://mall-pre.springboot.cn",
                ws: true,
                //secure: true,//如果是https,需要这个参数
                changeOrigin: true,//将主机的点设为原点
                pathRewrite: {
                    '^api': ''
                }
            }
        }
    }
}